define(["jquery","bbcare"],function($,$bb){
	var servers = {};

	/**
	 * 处理打印年龄
	 */
	var handleAge = function(actualDays,pregnancyDay){
		var age = {};
		var day = actualDays;
		pregnancyDay = !pregnancyDay || pregnancyDay == 0 ? 280 : pregnancyDay;
        if (actualDays < 365 * 2 && pregnancyDay < 37 * 7) {
            day = actualDays - (280 - pregnancyDay);
        }
        if (day < 0) {
            age.year = 0;
            age.week = 0;
            age.day = day;
        } else {
            age.year = Math.floor(day / 365);
            age.week = Math.floor(day % 365 / 7);
            age.day = Math.floor(day % 365 % 7);
        }
        return age;
	}

	/**
	 * 处理基本信息
	 */
	servers.handleInfo = function(data){
		if( data.actualDays ) data.actualMonth = (data.actualDays / 31.4).toFixed(1);
		if( data.correctDays ) data.correctMonth = (data.correctDays / 31.4).toFixed(1);
		data.agePrint = handleAge(data.actualDays,data.pregnancyDay);
		return data;
	}

	/**
	 * 计算出总发育商
	 */
	servers.countScore = function(data,info){
		var totalScore = Number(data.sportsScore) + Number(data.fineActionScore) + Number(data.adaptabilityScore) + Number(data.languageScore) + Number(data.personalScore);
		data.score = ( totalScore * 100 / 5 / info.actualMonth ).toFixed(1);
		if( data.sportsScore * 1.0 < 85 ) data.sportsFlag = true;
	    if( data.fineActionScore * 1.0 < 85 ) data.fineActionFlag = true;
	    if( data.adaptabilityScore * 1.0 < 85 )	data.adaptabilityFlag = true;
	    if( data.languageScore * 1.0 < 85 )	data.languageFlag = true;
	    if( data.personalScore * 1.0 < 85 )	data.personalFlag = true;
	    if( data.score * 1.0 > 130 ) data.score1 = true;
	    else if( data.score * 1.0 > 114 ) data.score2 = true;
	    else if( data.score * 1.0 > 85 ) data.score3 = true;
	    else if( data.score * 1.0 > 70 ) data.score4 = true;
	    else data.score5 = true;
		return data;
	}

	return servers;
});